#pragma once
#include "TypeDefs.h"
#include "vector2.h"

class Rect
{
public:
	void operator=(const Rect &src);
	Rect(const Rect& src);
public:
	~Rect();
	Rect();
	Rect(int x, int y, int w, int h);
	Rect(float x, float y, float w, float h);
	Rect(int x, int y, int w, int h, float zRotation);
	Rect(float x, float y, float w, float h, float zRotation);
	bool CollidesWith(const Rect &other);
	bool IsAxisAligned();
	Rect CreateAxisAlignedBoundingBox();
	void SetOrigin(vector2 origin);
	void SetOrigin(float x, float y);
	vector2 GetOrigin() const;

public:
	float X() const { return x; };
	float Y() const { return y; };
	float W() const { return w; };
	float H() const { return h; };
	float GetRotation() const { return zR; }

	vector2 *GetPoints(uint *ppCountOut) const { 
		if(ppCountOut != NULL) {
			(*ppCountOut) = 4;
		}
		return m_points;
	};

private:
	void init();
	void destroy();
	void UpdatePoints();

protected:
	float x, y, w, h;
	vector2 *m_points;
	vector2 m_origin;
	float zR;
};